package tech.lq0.dreamaticvoyage.client.models.entity;// Made with Blockbench 4.12.2
// Exported for Minecraft version 1.17 or later with Mojang mappings
// Paste this class into your mod and generate all required imports

import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import tech.lq0.dreamaticvoyage.Utils;

@OnlyIn(Dist.CLIENT)
public class FukamizuFishModel<T extends Entity> extends HierarchicalModel<T> {

    public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(Utils.loc("fukamizu_fish"), "main");
    private final ModelPart root;
    private final ModelPart body_front;
    private final ModelPart body_back;

    public FukamizuFishModel(ModelPart root) {
        this.root = root;
        this.body_front = root.getChild("body_front");
        this.body_back = this.body_front.getChild("body_back");
    }

    public static LayerDefinition createBodyLayer() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();

        PartDefinition body_front = partdefinition.addOrReplaceChild("body_front", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, -9.0F, -3.0F, 3.0F, 6.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));

        PartDefinition body_back = body_front.addOrReplaceChild("body_back", CubeListBuilder.create().texOffs(0, 21).addBox(-1.0F, -8.5F, 7.0F, 2.0F, 5.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));

        PartDefinition front_r1 = body_back.addOrReplaceChild("front_r1", CubeListBuilder.create().texOffs(0, 31).addBox(1.0F, -1.0F, -1.0F, 0.0F, 1.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.0F, -3.4F, 10.0F, -0.1745F, 0.0F, 0.0F));

        PartDefinition dorsal_back = body_back.addOrReplaceChild("dorsal_back", CubeListBuilder.create().texOffs(24, 20).addBox(1.0F, -3.0F, 3.0F, 0.0F, 3.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.0F, -9.0F, 4.0F));

        PartDefinition tailfin = body_back.addOrReplaceChild("tailfin", CubeListBuilder.create().texOffs(26, 0).addBox(1.0F, -6.0F, -1.0F, 0.0F, 6.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.0F, -3.0F, 18.0F));

        PartDefinition dorsal_front = body_front.addOrReplaceChild("dorsal_front", CubeListBuilder.create().texOffs(26, 18).addBox(0.0F, -12.0F, 3.0F, 0.0F, 3.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));

        PartDefinition head = body_front.addOrReplaceChild("head", CubeListBuilder.create().texOffs(24, 28).addBox(-1.0F, -9.0F, -7.0F, 2.0F, 6.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));

        PartDefinition leftfin = body_front.addOrReplaceChild("leftfin", CubeListBuilder.create(), PartPose.offset(1.5F, -4.0F, 1.0F));

        PartDefinition leftfin_r1 = leftfin.addOrReplaceChild("leftfin_r1", CubeListBuilder.create().texOffs(12, 31).addBox(0.0F, 0.0F, -3.0F, 0.0F, 3.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, -1.0472F));

        PartDefinition rightfin = body_front.addOrReplaceChild("rightfin", CubeListBuilder.create(), PartPose.offset(1.5F, -4.0F, 1.0F));

        PartDefinition rightfin_r1 = rightfin.addOrReplaceChild("rightfin_r1", CubeListBuilder.create().texOffs(36, 28).addBox(0.0F, 0.0F, -3.0F, 0.0F, 3.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-3.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0472F));

        return LayerDefinition.create(meshdefinition, 64, 64);
    }

    @Override
    public void setupAnim(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
        float f = 1.0F;
        float f1 = 1.0F;
        if (!entity.isInWater()) {
            f = 1.3F;
            f1 = 1.7F;
        }

        this.body_back.yRot = -f * 0.1F * Mth.sin(f1 * 0.6F * ageInTicks);
    }

    @Override
    public ModelPart root() {
        return this.root;
    }
}